package logicaDePredicados;
/**
 * This class represents a Constant in Predicate Logic. Constants can be used as a parameter 
 * for a LogicPredicate function.
 * 
 * @author Francisco Gindre
 *
 * @param <TYPE>
 */
public class PredicateConstant <TYPE> extends PredicateLogic{
	private TYPE value;

	public PredicateConstant(TYPE value,String name) {
		super();
		this.value = value;
		setName(name);
		
	}
	public PredicateConstant(TYPE value) {
		super();
		this.value = value;
		setName(value.toString());
		
	}

	/**
	 * @return the value
	 */
	
	public TYPE getValue() {
		return value;
	}
	
	/* Regardless the name they have, two PredicateConstant<TYPE> are equal
	 * when their values are.
	 * (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	
	public boolean equals(Object o) { 
		
		if (o.getClass() == this.getClass()) { 
			PredicateConstant<?> p1 = (PredicateConstant<?>) o;
			return p1.getValue().equals(this.value)
			&& p1.getValue().equals(this.value);

		}

		return(false);
	}
	
	@Override
	
	public int hashCode() {
		int hash = 1;
	    hash = hash * 31 + value.hashCode();
	    
	    return hash;	 
	}


		

}
